<%@ page import="id.co.gomobile.assessment.Item" %>

<%@page import="id.co.gomobile.assessment.Test"%><html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>Create Item</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>Create Item</h1>

    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>

    <g:hasErrors bean="${itemInstance}">
    <div class="errors">
        <g:renderErrors bean="${itemInstance}" as="list" />
    </div>
    <br/>
    </g:hasErrors>

    <g:form action="update" method="post" >
        <g:hiddenField name="id" value="${itemInstance?.id}" />
        <g:hiddenField name="version" value="${itemInstance?.version}" />

    <div class="form">

    <fieldset>        
        <h3>Item Details</h3>
        
        <br/>

        <label for="name" class="required ${hasErrors(bean: itemInstance, field: 'test', 'errors')}">Test :</label>
        <div class="value">
            <g:select name="test.id" from="${Test.list()}" optionKey="id" optionValue="name" value="${itemInstance?.test?.id}" disabled="true" />
            <g:hiddenField name="test.id" value="${itemInstance?.test?.id}" />
        </div>

        <br/>

        <label for="name" class="required ${hasErrors(bean: itemInstance, field: 'text', 'errors')}">Text :</label>
        <div class="value">
            <g:textArea name="text" value="${itemInstance?.text}" />
        </div>
        <div class="notes">Support SyntaxHighlighter. Click <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter:Usage">here</a> for usage guide.</div>
                
        <br/>

        <label for="category" class="${hasErrors(bean: itemInstance, field: 'category', 'errors')}">Category :</label>
        <div class="value">
            <g:select name="category" from="${categories}" noSelection="${['': '-']}" value="${itemInstance?.category}" />
            <a href="#" onclick="return addCategory(document.getElementById('category'))">Add</a>
        </div>

        <br/>
        <br/>

        <div class="buttons">
            <span class="button"><g:submitButton name="update" class="save" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
        </div>
    </fieldset>

    </div>
    </g:form>
    
    </div>
    </body>
</html>